package main

import (
	engine2 "gitee.com/jnshao/go-start/projects/crawler/engine"
	"gitee.com/jnshao/go-start/projects/crawler/persist"
	"gitee.com/jnshao/go-start/projects/crawler/scheduler"
	"gitee.com/jnshao/go-start/projects/crawler/zhenai/parser"
)

const url = "http://www.zhenai.com/zhenghun"

func main() {
	c, err := persist.ItemSaver("dating_profile")
	if err != nil {
		panic(err)
	}
	e := engine2.ConcurrentEngine{
		//接口的实现：指针接收者的实现只能以指针方式使用；值接收者都可
		//实现接口必须重写接口所有方法
		Scheduler:        &scheduler.QueueScheduler{},
		WorkerCount:      100,
		ItemChan:         c,
		RequestProcessor: engine2.Worker,
	}
	f := engine2.NewFuncParser(parser.ParseCityList, "ParseCityList", nil)
	e.Run(engine2.Request{ //指针接收函数，必须必须先赋值给变量才能使用
		URL:    url,
		Parser: &f})

	// engine.ConcurrentEngine{
	// 	Scheduler:   &scheduler.SimpleScheduler{},
	// 	WorkerCount: 100,
	// }.Run(engine.Request{
	// 	URL:        url,
	// 	ParserFunc: parser.ParseCityList})

	// engine.SimpleEngine{}.Run(engine.Request{
	// 	URL:        url,
	// 	ParserFunc: parser.ParseCityList,
	// })
}
